Removes all items from the collection and permanently destroys all storage.
Syntax
Visual Basic (Declaration) | |
---|
Public Sub Clear() |
Example
BPlusTree/BPlusTree.Test/BasicTests.cs
C# | Copy Code |
---|
int iterations = 5;
int limit = 255;
using (BPlusTree<int, string> data = Create(Options))
{
data.EnableCount();
List<int> numbers = new List<int>();
while (iterations-- > 0)
{
data.Clear();
numbers.Clear();
data.DebugSetValidateOnCheckpoint(true);
for (int i = 0; i < limit; i++)
{
int id = Random.Next(limit);
if (!numbers.Contains(id))
{
numbers.Add(id);
data.Add(id, "V" + id);
}
}
Assert.AreEqual(numbers.Count, data.Count);
foreach (int number in numbers)
Assert.IsTrue(data.Remove(number));
Assert.AreEqual(0, data.Count);
}
} |
VB.NET | Copy Code |
---|
Dim iterations As Integer = 5
Dim limit As Integer = 255
Using data As BPlusTree(Of Integer, String) = Create(Options)
data.EnableCount()
Dim numbers As New List(Of Integer)()
While System.Math.Max(System.Threading.Interlocked.Decrement(iterations),iterations + 1) > 0
data.Clear()
numbers.Clear()
data.DebugSetValidateOnCheckpoint(True)
Dim i As Integer = 0
While i < limit
Dim id As Integer = Random.[Next](limit)
If Not numbers.Contains(id) Then
numbers.Add(id)
data.Add(id, "V" + id)
End If
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Assert.AreEqual(numbers.Count, data.Count)
For Each number As Integer In numbers
Assert.IsTrue(data.Remove(number))
Next
Assert.AreEqual(0, data.Count)
End While
End Using |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also